{% extends 'base.html' %}  <!-- 继承基础模板（需包含 Bootstrap 样式） -->
{% block content %}
  <div class="container mt-4">
    <h1 class="mb-4">添加新内容</h1>
    <form method="post" action="{% url 'add_content' %}" class="shadow p-4 bg-white rounded">
      {% csrf_token %}
      <!-- 标题输入 -->
      <div class="form-group mb-3">
        <label for="title" class="font-weight-bold">标题</label>
        <input type="text" class="form-control" id="title" name="title" required
               placeholder="请输入标题（必填，最长 100 字）" maxlength="100">
      </div>
      <!-- 正文输入 -->
      <div class="form-group mb-3">
        <label for="content" class="font-weight-bold">正文</label>
        <textarea class="form-control" id="content" name="content" rows="8" required
                  placeholder="请输入正文（必填，最少 10 字）" minlength="10"></textarea>
      </div>
      <!-- 标签输入 -->
      <div class="form-group mb-3">
        <label for="tags" class="font-weight-bold">标签（可选，逗号分隔）</label>
        <input type="text" class="form-control" id="tags" name="tags"
               placeholder="示例：技术,教程,Python">
      </div>
      <!-- 操作按钮 -->
      <div class="d-flex justify-content-between">
        <button type="submit" class="btn btn-primary btn-lg">保存内容</button>
        <a href="{% url 'content_list' %}" class="btn btn-secondary btn-lg">取消</a>
      </div>
    </form>
    <!-- 反馈信息（使用 Django 消息框架） -->
    {% if messages %}
      <div class="mt-4">
        {% for message in messages %}
          <div class="alert alert-{{ message.tags }} alert-dismissible fade show" role="alert">
            {{ message }}
            <button type="button" class="close" data-dismiss="alert" aria-label="Close">
              <span aria-hidden="true">&times;</span>
            </button>
          </div>
        {% endfor %}
      </div>
    {% endif %}
  </div>
{% endblock %}